package com.yanqu.road.server.manger.activity.daomu.pb;

import com.yanqu.road.entity.activity.daomu.*;
import com.yanqu.road.entity.activity.daomu.config.*;
import com.yanqu.road.entity.activity.daomu.data.DaoMuActivityUserCollectionData;
import com.yanqu.road.entity.activity.daomu.data.DaoMuActivityUserOfferRewardData;
import com.yanqu.road.entity.activity.daomu.param.DaoMuCreateNpcRes;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.pb.activity.DaoMuProto;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.ServerLanguageMgr;
import com.yanqu.road.server.manger.activity.daomu.DaoMuActivityPveRoom;
import com.yanqu.road.server.manger.activity.daomu.DaoMuActivityUser;
import com.yanqu.road.utils.property.PropertyHelper;


import java.math.BigDecimal;
import java.util.ArrayList;

import java.util.List;
import java.util.Map;


public class DaoMuActivityPb {

    /**
     * 活动配置PB
     * @param daoMuActivityConfig
     * @return
     */
    public static DaoMuProto.DaoMuActivityConfig.Builder syncConfig(DaoMuActivityConfig daoMuActivityConfig, String language) {
        DaoMuProto.DaoMuActivityConfig.Builder builder = DaoMuProto.DaoMuActivityConfig.newBuilder();
        //关卡
        for (DaoMuMissionConfig daoMuMissionConfig : daoMuActivityConfig.getDaoMuMissionConfigMap().values()) {
            DaoMuProto.DaoMuMissionConfig.Builder mission = DaoMuActivityPb.buildMissionConfigPb(daoMuMissionConfig,language);
            builder.addMissionConfig(mission);
        }
        //NPC
        for (DaoMuNpcConfig daoMuNpcConfig : daoMuActivityConfig.getDaoMuNpcConfigMap().values()) {
            DaoMuProto.DaoMuNpcConfig.Builder npcConfig = DaoMuActivityPb.buildNpcConfigPb(daoMuNpcConfig,language);
            builder.addNpcConfig(npcConfig);
        }
        //物品
        for (DaoMuCurioConfig daoMuCurioConfig : daoMuActivityConfig.getDaoMuCurioConfigList()) {
            DaoMuProto.DaoMuCurioConfig.Builder curioConfig = DaoMuActivityPb.buildCurioConfigPb(daoMuCurioConfig,language);
            builder.addCurioConfig(curioConfig);
        }
        //玩家等级
        for (DaoMuPlayerLevelConfig daoMuPlayerLevelConfig : daoMuActivityConfig.getDaoMuLevelConfigMap().values()) {
            DaoMuProto.DaoMuPlayerLevelConfig.Builder levelConfig = DaoMuActivityPb.buildPlayerLevelConfigPb(daoMuPlayerLevelConfig);
            builder.addPlayerLevelConfig(levelConfig);
        }
        //技能
        for (DaoMuSkillConfig daoMuSkillConfig : daoMuActivityConfig.getDaoMuSkillConfigMap().values()) {
            DaoMuProto.DaoMuSkillConfig.Builder skillConfig = DaoMuActivityPb.buildSkillConfigPb(daoMuSkillConfig,language);
            builder.addSkillConfig(skillConfig);
        }
        //开棺宝箱
        for (DaoMuCrowbarBoxConfig daoMuCrowbarBoxConfig : daoMuActivityConfig.getCrowbarBoxConfigMap().values()) {
            DaoMuProto.DaoMuCrowbarBoxConfig.Builder configPb = DaoMuActivityPb.buildCrowbarBoxConfigPb(daoMuCrowbarBoxConfig,language);
            builder.addCrowbarBoxConfig(configPb);
        }
        //开棺宝箱进度
        for (DaoMuProgressConfig progressConfig : daoMuActivityConfig.getProgressConfigMap().values()) {
            DaoMuProto.DaoMuProgressConfig.Builder configPb = DaoMuActivityPb.buildProgressConfigPb(progressConfig);
            builder.addProgressConfig(configPb);
        }
        //摸金等级
        for (DaoMuCaptainConfig config : daoMuActivityConfig.getCaptainConfigMap().values()) {
            DaoMuProto.DaoMuCaptainConfig.Builder configPb = DaoMuActivityPb.buildCaptainConfigPb(config);
            builder.addCaptainConfig(configPb);
        }
        if (daoMuActivityConfig.getActivityInfo().getType() == eActivityType.DaoMu.getValue()) {
            //PVP
            for (DaoMuPvpConfig config : daoMuActivityConfig.getPvpConfigMap().values()) {
                DaoMuProto.DaoMuPvpConfig.Builder configPb = DaoMuActivityPb.buildPvpConfigPb(config);
                builder.addPvpConfig(configPb);
            }
            // pvp技能
            for (DaoMuPvpSkillConfig pvpSkillConfig : daoMuActivityConfig.getPvpSkillConfigMap().values()) {
                builder.addPvpSkillConfig(buildPvpSkillConfigPb(pvpSkillConfig, language));
            }
            // pvp榜单
            for (DaoMuPvpRankConfig pvpRankConfig : daoMuActivityConfig.getPvpRankConfigMap().values()) {
                builder.addPvpRankConfig(buildPvpRankConfigPb(pvpRankConfig));
            }
        }
        return builder;
    }

    /**
     * 构建技能配置
     * @param daoMuSkillConfig
     * @return
     */
    public static DaoMuProto.DaoMuSkillConfig.Builder buildSkillConfigPb(DaoMuSkillConfig daoMuSkillConfig, String language) {
        DaoMuProto.DaoMuSkillConfig.Builder builder = DaoMuProto.DaoMuSkillConfig.newBuilder();
        builder.setId(daoMuSkillConfig.getId());
        builder.setSkillId(daoMuSkillConfig.getSkillId());
        builder.setLevel(daoMuSkillConfig.getLevel());
        builder.setName(ServerLanguageMgr.getContent(daoMuSkillConfig.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(daoMuSkillConfig.getDesc(), language));
        builder.setType(daoMuSkillConfig.getType());
        builder.setIcon(daoMuSkillConfig.getIcon());
        builder.setSkillPara(daoMuSkillConfig.getSkillPara());
        builder.setCombSkill(daoMuSkillConfig.getCombSkill());
        return builder;
    }

    /**
     * 构建玩家等级配置
     * @param daoMuPlayerLevelConfig
     * @return
     */
    public static DaoMuProto.DaoMuPlayerLevelConfig.Builder buildPlayerLevelConfigPb(DaoMuPlayerLevelConfig daoMuPlayerLevelConfig) {
        DaoMuProto.DaoMuPlayerLevelConfig.Builder builder = DaoMuProto.DaoMuPlayerLevelConfig.newBuilder();
        builder.setId(daoMuPlayerLevelConfig.getId());
        builder.setLevel(daoMuPlayerLevelConfig.getLevel());
        builder.setCost(Integer.valueOf(daoMuPlayerLevelConfig.getCost()));
        builder.setPvpCost(daoMuPlayerLevelConfig.getPvpCost());
        builder.setEndDowngrade(daoMuPlayerLevelConfig.getEndDowngrade());
        builder.setEndDropsExp(daoMuPlayerLevelConfig.getEndDropsExp());
        return builder;
    }

    /**
     * 构建物品配置
     * @param daoMuCurioConfig
     * @return
     */
    public static DaoMuProto.DaoMuCurioConfig.Builder buildCurioConfigPb(DaoMuCurioConfig daoMuCurioConfig, String language) {
        DaoMuProto.DaoMuCurioConfig.Builder builder = DaoMuProto.DaoMuCurioConfig.newBuilder();
        builder.setId(daoMuCurioConfig.getId());
        builder.setType(daoMuCurioConfig.getType());
        builder.setQuality(daoMuCurioConfig.getQuality());
        builder.setIcon(daoMuCurioConfig.getIcon());
        builder.setName(ServerLanguageMgr.getContent(daoMuCurioConfig.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(daoMuCurioConfig.getDesc(), language));
        builder.setFavoriteScore(daoMuCurioConfig.getFavoriteScore());
        builder.setCurioId(daoMuCurioConfig.getCurioId());
        builder.setLevel(daoMuCurioConfig.getLevel());
        builder.setCost(daoMuCurioConfig.getCost());
        builder.setBasePara(daoMuCurioConfig.getBasePara());
        builder.setUnlockSkillLevel(daoMuCurioConfig.getUnlockSkillLevel());
        builder.setAttributePara(daoMuCurioConfig.getAttributePara());
        builder.setUnlockCond(daoMuCurioConfig.getUnlockCond());
        return builder;
    }

    /**
     * 构建NPC配置
     * @param daoMuNpcConfig
     * @return
     */
    public static DaoMuProto.DaoMuNpcConfig.Builder buildNpcConfigPb(DaoMuNpcConfig daoMuNpcConfig, String language) {
        DaoMuProto.DaoMuNpcConfig.Builder builder = DaoMuProto.DaoMuNpcConfig.newBuilder();
        builder.setId(daoMuNpcConfig.getId());
        builder.setType(daoMuNpcConfig.getType());
        builder.setBoxFlag(daoMuNpcConfig.getBoxFlag());
        builder.setIcon(daoMuNpcConfig.getIcon());
        builder.setName(ServerLanguageMgr.getContent(daoMuNpcConfig.getName(),language));
        builder.setDesc(ServerLanguageMgr.getContent(daoMuNpcConfig.getDesc(), language));
        builder.setBasePara(daoMuNpcConfig.getBasePara());
        builder.setSkillId(daoMuNpcConfig.getSkillId());
        builder.setSpecialRewards(daoMuNpcConfig.getSpecialRewards());
        builder.setCollisionSize(daoMuNpcConfig.getCollisionSize());
        builder.setBornPara(daoMuNpcConfig.getBornPara());
        return builder;
    }

    /**
     * 构建开棺宝箱配置
     * @param config
     * @return
     */
    public static DaoMuProto.DaoMuCrowbarBoxConfig.Builder buildCrowbarBoxConfigPb(DaoMuCrowbarBoxConfig config, String language) {
        DaoMuProto.DaoMuCrowbarBoxConfig.Builder builder = DaoMuProto.DaoMuCrowbarBoxConfig.newBuilder();
        builder.setId(config.getId());
        builder.setName(ServerLanguageMgr.getContent(config.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(config.getDesc(), language));
        builder.setCost(config.getCost());
        builder.setItemWeights(config.getItemWeights());
        builder.setCurioWeights(config.getCurioWeights());
        builder.setProgressValueAdd(config.getProgressValueAdd());
        return builder;
    }

    /**
     * 构建开棺宝箱进度配置
     * @param config
     * @return
     */
    public static DaoMuProto.DaoMuProgressConfig.Builder buildProgressConfigPb(DaoMuProgressConfig config) {
        DaoMuProto.DaoMuProgressConfig.Builder builder = DaoMuProto.DaoMuProgressConfig.newBuilder();
        builder.setId(config.getId());
        builder.setProgressValue(config.getProgressValue());
        builder.setRewards(config.getRewards());
        return builder;
    }

    /**
     * 构建摸金等级配置
     * @param config
     * @return
     */
    public static DaoMuProto.DaoMuCaptainConfig.Builder buildCaptainConfigPb(DaoMuCaptainConfig config) {
        DaoMuProto.DaoMuCaptainConfig.Builder builder = DaoMuProto.DaoMuCaptainConfig.newBuilder();
        builder.setId(config.getId());
        builder.setLevel(config.getLevel());
        builder.setCost(config.getCost());
        builder.setPvpBasePara(config.getPvpBasePara());
        builder.setPvpArmsType(config.getPvpArmsType());
        return builder;
    }

    /**
     * 构建PVP配置
     * @param config
     * @return
     */
    public static DaoMuProto.DaoMuPvpConfig.Builder buildPvpConfigPb(DaoMuPvpConfig config) {
        DaoMuProto.DaoMuPvpConfig.Builder builder = DaoMuProto.DaoMuPvpConfig.newBuilder();
        builder.setId(config.getId());
        builder.setHome(config.getHome());
        builder.setBirthPoint(config.getBirthPoint());
        builder.setPeople(config.getPeople());
        builder.setBoxNum(config.getBoxNum());
        builder.setBoxWeights(config.getBoxWeights());
        builder.setBoxHits(config.getBoxHits());
        builder.setBoxRefreshTime(config.getBoxRefreshTime());
        builder.setMobsId(config.getMobsId());
        builder.setUpgradeNeedLevel(config.getUpgradeNeedLevel());
        builder.setCollapseCondPeople(config.getCollapseCondPeople());
        builder.setCollapseCondTime(config.getCollapseCondTime());
        builder.setShrinkCircle(config.getShrinkCircle());
        builder.setShrinkCircleHarm(config.getShrinkCircleHarm());
        builder.setDisuse(config.getDisuse());
        builder.setUpgradeNeedTime(config.getUpgradeNeedTime());
        return builder;
    }

    public static DaoMuProto.DaoMuPvpSkillConfig.Builder buildPvpSkillConfigPb(DaoMuPvpSkillConfig config, String language) {
        DaoMuProto.DaoMuPvpSkillConfig.Builder builder = DaoMuProto.DaoMuPvpSkillConfig.newBuilder();
        builder.setSkillId(config.getSkillId());
        builder.setType(config.getType());
        builder.setLevel(config.getLevel());
        builder.setName(ServerLanguageMgr.getContent(config.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(config.getDesc(), language));
        builder.setIcon(config.getIcon());
        builder.setSkillParam(config.getSkillPara());
        return builder;
    }

    public static DaoMuProto.DaoMuPvpRankConfig.Builder buildPvpRankConfigPb(DaoMuPvpRankConfig config) {
        DaoMuProto.DaoMuPvpRankConfig.Builder builder = DaoMuProto.DaoMuPvpRankConfig.newBuilder();
        builder.setId(config.getId());
        builder.setRound(config.getRound());
        builder.setRank(config.getRank());
        builder.setScore(config.getScore());
        return builder;
    }

    /**
     * 构建关卡配置
     * @param daoMuMissionConfig
     * @return
     */
    public static DaoMuProto.DaoMuMissionConfig.Builder buildMissionConfigPb(DaoMuMissionConfig daoMuMissionConfig, String language) {
        DaoMuProto.DaoMuMissionConfig.Builder builder = DaoMuProto.DaoMuMissionConfig.newBuilder();
        builder.setId(daoMuMissionConfig.getId());
        builder.setFloor(daoMuMissionConfig.getFloor());
        builder.setMap(daoMuMissionConfig.getMap());
        builder.setChapterName(ServerLanguageMgr.getContent(daoMuMissionConfig.getChapterName(), language));
        builder.setChapterDesc(daoMuMissionConfig.getChapterDesc());
        builder.setName(ServerLanguageMgr.getContent(daoMuMissionConfig.getName(), language));
        builder.setMobsAppearTime(daoMuMissionConfig.getMobsAppearTime());
        builder.setMobsId(daoMuMissionConfig.getMobsId());
        builder.setMobsAppearFrequency(daoMuMissionConfig.getMobsAppearFrequency());
        builder.setMobsEffects(daoMuMissionConfig.getMobsEffects());

        builder.setSpecialMobsAppearTime(daoMuMissionConfig.getSpecialMobsAppearTime());
        builder.setSpecialMobsId(daoMuMissionConfig.getSpecialMobsId());
        builder.setSpecialMobsNum(daoMuMissionConfig.getSpecialMobsNum());
        builder.setSpecialMobsEffects(daoMuMissionConfig.getSpecialMobsEffects());

        builder.setBossId(daoMuMissionConfig.getBossId());
        builder.setBossAppearTime(daoMuMissionConfig.getBossAppearTime());
        builder.setBossEffects(daoMuMissionConfig.getBossEffects());

        builder.setRewards(daoMuMissionConfig.getRewards());
        builder.setSpecialRewards(daoMuMissionConfig.getSpecialRewards());

        builder.setBountyMonster(daoMuMissionConfig.getBountyMonster());
        builder.setBountyRewards(daoMuMissionConfig.getBountyRewards());
        builder.setSpecialBountyRewards(daoMuMissionConfig.getSpecialBountyRewards());

        builder.setNeedFavoriteScore(daoMuMissionConfig.getNeedFavoriteScore());

        builder.setSpecialGameRewards(daoMuMissionConfig.getSpecialGameRewards());
        builder.setSpecialBountyGameRewards(daoMuMissionConfig.getSpecialBountyGameRewards());
        builder.setPassFavoriteScore(daoMuMissionConfig.getPassFavoriteScore());

        builder.setUnlock(daoMuMissionConfig.getUnlock());
        builder.setPartnerId(daoMuMissionConfig.getPartnerId());
        builder.setParam(daoMuMissionConfig.getParam());
        builder.setSkillList(daoMuMissionConfig.getSkillList());

        builder.setMobsNumMax(daoMuMissionConfig.getMobsNumMax());
        return builder;
    }

    /**
     * 构造 玩家信息 PB
     * @param daoMuActivityUser
     * @return
     */
    public static DaoMuProto.DaoMuPlayerInfo createPlayerInfoPb(DaoMuActivityUser daoMuActivityUser) {
        DaoMuProto.DaoMuPlayerInfo.Builder builder = DaoMuProto.DaoMuPlayerInfo.newBuilder();
        builder.setUserId(daoMuActivityUser.getUserId());
        builder.setRoleId(daoMuActivityUser.getRoleId());
        builder.setPassesId(daoMuActivityUser.getPassesId());
        builder.setEnergy(daoMuActivityUser.getEnergy());
        for (DaoMuActivityUserCollectionData collection : daoMuActivityUser.getUserCollectionDataMap().values()) {
            DaoMuProto.DaoMuCollectionItem collectionItem = createCollectionItemPb(collection);
            builder.addCollection(collectionItem);
        }
        //活动内的道具
        builder.setActivityProp(daoMuActivityUser.getProp());
        //解锁的角色
        String[] roleIds = daoMuActivityUser.getUnlockRoleIds().split(",");
        for (String roleId : roleIds) {
            if (!roleId.equals("")) {
                builder.addUnlockRoleId(Integer.valueOf(roleId));
            }
        }
        //进度宝箱
        builder.setProgressBoxId(daoMuActivityUser.getProgressBoxId());
        builder.setBoxProgress(daoMuActivityUser.getBoxProgress());
        //藏品分
        builder.setCollectionScore(daoMuActivityUser.getCollectionScore());
        //是否通关
        builder.setPassAllFlag(daoMuActivityUser.getPassAllFlag());
        builder.setHistoryMaxPassesId(daoMuActivityUser.getHistoryMaxPassesId());
        //血脉关卡击杀数量
        for (Map.Entry<String, Integer> entry : daoMuActivityUser.getXmKillNumMap().entrySet()) {
            DaoMuProto.DaoMuXmPassesKillNumItem.Builder item = DaoMuProto.DaoMuXmPassesKillNumItem.newBuilder();
            item.setPassesId(Integer.valueOf(entry.getKey()));
            item.setKillNum(entry.getValue());
            builder.addXmPassesKillNumItem(item);
        }
        //过关的关卡
        for (int passesId : daoMuActivityUser.getPassPassesIds()) {
            builder.addPassPassesIds(passesId);
        }
        builder.setSelectSkillId(daoMuActivityUser.getSelectSkillId());
        return builder.build();
    }

    /**
     * 构造 藏品 PB
     * @param collection
     * @return
     */
    public static DaoMuProto.DaoMuCollectionItem createCollectionItemPb(DaoMuActivityUserCollectionData collection) {
        DaoMuProto.DaoMuCollectionItem.Builder builder = DaoMuProto.DaoMuCollectionItem.newBuilder();
        builder.setId(collection.getCollectionId());
        builder.setLevel(collection.getCollectionLevel());
        builder.setNum(collection.getCollectionPropNum());
        return builder.build();
    }

    /**
     * 构建 npc PB
     * @param daoMuNpc
     * @return
     */
    public static DaoMuProto.DaoMuNpcItem createDaoMuNpcItem(DaoMuNpc daoMuNpc) {
        DaoMuProto.DaoMuNpcItem.Builder builder = DaoMuProto.DaoMuNpcItem.newBuilder();
        builder.setId(daoMuNpc.getId());
        builder.setMonsterId(daoMuNpc.getNpcId());
        builder.setShowSecond(daoMuNpc.getCreateTimeSecond());
        if (daoMuNpc.getDropProp() != null) {
            for (DaoMuBattlePropItem daoMuBattlePropItem : daoMuNpc.getDropProp().values()) {
                DaoMuProto.DaoMuBattlePropItem daoMuBattlePropItemPb = DaoMuActivityPb.createDaoMuBattlePropItem(daoMuBattlePropItem);
                builder.addPropList(daoMuBattlePropItemPb);
            }
        }
        return builder.build();
    }

    /**
     * 构建 局内道具 PB
     * @param daoMuBattlePropItem
     * @return
     */
    public static DaoMuProto.DaoMuBattlePropItem createDaoMuBattlePropItem(DaoMuBattlePropItem daoMuBattlePropItem) {
        DaoMuProto.DaoMuBattlePropItem.Builder builder = DaoMuProto.DaoMuBattlePropItem.newBuilder();
        builder.setBattlePropId(daoMuBattlePropItem.getBattlePropId());
        builder.setCurioId(daoMuBattlePropItem.getCurioId());
        return builder.build();
    }

    /**
     * 构建 技能 item
     * @param daoMuSkill
     * @return
     */
    public static DaoMuProto.DaoMuSkillItem createDaoMuSkillItem(DaoMuSkill daoMuSkill, DaoMuSkillConfig daoMuSkillConfig) {
        DaoMuProto.DaoMuSkillItem.Builder builder = DaoMuProto.DaoMuSkillItem.newBuilder();
        builder.setId(daoMuSkill.getSkillId());
        if (daoMuSkillConfig == null) {
            builder.setLevel(daoMuSkill.getSkillLevel());
        } else {
            builder.setLevel(daoMuSkillConfig.getLevel());
        }
        if (daoMuSkill.getNextLevel() > 0) {
            builder.setNextLevel(daoMuSkill.getNextLevel());
        }
        return builder.build();
    }

    /**
     * 构建 DaoMuPveRefreshNpcRespMsg PB
     * @param daoMuCreateNpc
     * @return
     */
    public static DaoMuProto.DaoMuPveRefreshNpcRespMsg.Builder createPveRefreshNpcRespMsgPb(DaoMuCreateNpcRes daoMuCreateNpc) {
        DaoMuProto.DaoMuPveRefreshNpcRespMsg.Builder builder = DaoMuProto.DaoMuPveRefreshNpcRespMsg.newBuilder();
        builder.setRet(0);
        //boss
        if (daoMuCreateNpc.getBoss() != null) {
            DaoMuProto.DaoMuNpcItem boss = DaoMuActivityPb.createDaoMuNpcItem(daoMuCreateNpc.getBoss());
            builder.setBoss(boss);
        }
        //小怪
        if (daoMuCreateNpc.getMobs() != null) {
            for (DaoMuNpc daoMuNpc : daoMuCreateNpc.getMobs().values()) {
                DaoMuProto.DaoMuNpcItem mobs = DaoMuActivityPb.createDaoMuNpcItem(daoMuNpc);
                builder.addMobs(mobs);
            }
        }
        //特殊怪
        if (daoMuCreateNpc.getSpecial() != null) {
            for (DaoMuNpc daoMuNpc : daoMuCreateNpc.getSpecial().values()) {
                DaoMuProto.DaoMuNpcItem special = DaoMuActivityPb.createDaoMuNpcItem(daoMuNpc);
                builder.addSpecial(special);
            }
        }
        return builder;
    }

    /**
     * 玩家PVE局内信息
     * @param daoMuActivityPveRoom
     * @return
     */
    public static DaoMuProto.DaoMuPveRoomPlayer.Builder createPveRoomPlayerPb(DaoMuActivityPveRoom daoMuActivityPveRoom) {
        DaoMuProto.DaoMuPveRoomPlayer.Builder builder = DaoMuProto.DaoMuPveRoomPlayer.newBuilder();
        builder.setExp(daoMuActivityPveRoom.getExp());
        builder.setLevel(daoMuActivityPveRoom.getLevel());
        builder.setTotalHp(daoMuActivityPveRoom.getTotalHp());
        builder.setReduceHp(daoMuActivityPveRoom.getReduceHp());
        builder.setAttRandSeed(daoMuActivityPveRoom.getAttRandSeed());
        //主动技能
        for (DaoMuSkill daoMuSkill : daoMuActivityPveRoom.getActiveSkillMap().values()) {
            //获取觉醒配置
            DaoMuSkillConfig daoMuSkillConfig = daoMuActivityPveRoom.getRealDaoMuSkillConfig(daoMuSkill);
            DaoMuProto.DaoMuSkillItem skillItem = DaoMuActivityPb.createDaoMuSkillItem(daoMuSkill, daoMuSkillConfig);
            builder.addActiveSkillList(skillItem);
        }
        //辅助技能
        for (DaoMuSkill daoMuSkill : daoMuActivityPveRoom.getPassiveSkillMap().values()) {
            //获取觉醒配置
            DaoMuSkillConfig daoMuSkillConfig = daoMuActivityPveRoom.getRealDaoMuSkillConfig(daoMuSkill);
            DaoMuProto.DaoMuSkillItem skillItem = DaoMuActivityPb.createDaoMuSkillItem(daoMuSkill, daoMuSkillConfig);
            //获取觉醒等级
            builder.addPassiveSkillList(skillItem);
        }
        //属性
        for (DaoMuAttribute daoMuAttribute : daoMuActivityPveRoom.getAttributeMap().values()) {
            DaoMuProto.DaoMuBattleAttribute.Builder attribute = DaoMuActivityPb.createBattleAttributePb(daoMuAttribute);
            builder.addBattleAttributeList(attribute);
        }
        //set 是否可看广告
        builder.setSelectAllSkillFlag(daoMuActivityPveRoom.getSkillSelectAllTime() <= 0);
        //重随技能次数
        builder.setRandomSelectSkillNum(daoMuActivityPveRoom.getRandomSelectSkillNum());
        return builder;
    }

    /**
     * 构建 DaoMuBattleAttribute PB
     * @param daoMuAttribute
     * @return
     */
    public static DaoMuProto.DaoMuBattleAttribute.Builder createBattleAttributePb(DaoMuAttribute daoMuAttribute) {
        DaoMuProto.DaoMuBattleAttribute.Builder builder = DaoMuProto.DaoMuBattleAttribute.newBuilder();
        builder.setId(daoMuAttribute.getId());
        builder.setValue(daoMuAttribute.getValue().longValue());
        return builder;
    }

    /**
     * 构建 DaoMuOfferRewardItem PB
     * @param offerRewardData
     * @return
     */
    public static DaoMuProto.DaoMuOfferRewardItem.Builder createOfferRewardItemPb(DaoMuActivityUserOfferRewardData offerRewardData) {
        DaoMuProto.DaoMuOfferRewardItem.Builder builder = DaoMuProto.DaoMuOfferRewardItem.newBuilder();
        builder.setNpcId(offerRewardData.getNpcId());
        builder.setStatus(offerRewardData.getStatus());
        return builder;
    }

    /**
     * 解析DaoMuDamageBuffList
     * @param daoMuDamageBuffList
     * @return
     */
    public static List<DaoMuSkillDamageBuff> parseDamageBuffList(List<DaoMuProto.DaoMuDamageBuff> daoMuDamageBuffList) {
        List<DaoMuSkillDamageBuff> list = new ArrayList<>();
        for (DaoMuProto.DaoMuDamageBuff daoMuDamageBuff : daoMuDamageBuffList) {
            DaoMuSkillDamageBuff data = new DaoMuSkillDamageBuff();
            data.setBuffSkillId(daoMuDamageBuff.getBuffSkillId());
            data.setBuffType(daoMuDamageBuff.getBuffType());
            data.setBuffValue(daoMuDamageBuff.getBuffValue());
            list.add(data);
        }
        return list;
    }

    /**
     * 解析 DaoMuSkill
     * @param skillItem
     * @return
     */
    public static DaoMuSkill parSkillInfo(DaoMuProto.DaoMuSkillItem skillItem) {
        DaoMuSkill daoMuSkill = new DaoMuSkill();
        daoMuSkill.setSkillId(skillItem.getId());
        daoMuSkill.setSkillLevel(skillItem.getLevel());
        daoMuSkill.setCollectionId(skillItem.getCollectionId());
        return daoMuSkill;
    }

    /**
     * 解析 DaoMuAttribute
     * @param attribute
     * @return
     */
    public static DaoMuAttribute parAttribute(DaoMuProto.DaoMuBattleAttribute attribute) {
        DaoMuAttribute daoMuAttribute = new DaoMuAttribute(attribute.getId(), BigDecimal.valueOf(attribute.getValue()), BigDecimal.valueOf(attribute.getMaxVale()));
        return daoMuAttribute;
    }

    /**
     * 构建 DaoMuStatementInfoItem PB
     * @param daoMuStatementInfo
     * @param daoMuActivityUser
     * @param passesReward 过关奖励
     * @param offerReward 悬赏奖励
     * @return
     */
    public static DaoMuProto.DaoMuStatementInfoItem.Builder createDaoMuStatementInfoItemPb(DaoMuStatementInfo daoMuStatementInfo, DaoMuActivityUser daoMuActivityUser, DaoMuReward passesReward, DaoMuReward offerReward) {
        DaoMuProto.DaoMuStatementInfoItem.Builder builder = DaoMuProto.DaoMuStatementInfoItem.newBuilder();
        builder.setStatus(daoMuStatementInfo.isStatus());
        builder.setKillNum(daoMuStatementInfo.getKillNum());
        builder.setBattleTime(daoMuStatementInfo.getBattleTime());
        builder.setReward(PropertyHelper.parsePropertyToString(passesReward.getReward()));
        builder.setActivityReward(PropertyHelper.parsePropertyToString(passesReward.getActivityReward()));
        builder.setRank(daoMuActivityUser.getPveRank());
        builder.setPlayerInfo(createPlayerInfoPb(daoMuActivityUser));
        builder.setOfferReward(PropertyHelper.parsePropertyToString(offerReward.getReward()));
        builder.setOfferActivityReward(PropertyHelper.parsePropertyToString(offerReward.getActivityReward()));
        return builder;
    }
}
